Skip to content

Conversation

FamALouiz
Copy link

References to issue

Resolves #317

Brief description of what was implemented

  • Added longest alternating subsequence
  • Added longest alternating subsequence tests

Comments

The algorithm works in O(n) using a dp + greedy solution. It does not return the actualy subsequence; instead, it returns only the length.

decreasing = increasing + 1

# Return the maximum length
return max(increasing, decreasing)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to return the increasing sequence as well and not just the length.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@FamALouiz FamALouiz requested a review from czgdp1807 March 11, 2025 11:59
@FamALouiz
Copy link
Author

@czgdp1807 Could you please review this? Changes have been made.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Longest Alternating Subsequence
2 participants